# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Arjan Timmerman <arjan@soufly.nl>
# Contributor: Tor Krill

pkgname=autogen
pkgver=5.18.16
pkgrel=2
pkgdesc="A tool designed to simplify the creation and maintenance of programs that contain large amounts of repetitious text"
arch=('x86_64')
url="https://www.gnu.org/software/autogen/"
license=('GPL3')
depends=('guile' 'libxml2' 'perl')
makedepends=('autogen' 'chrpath')
source=(https://ftp.gnu.org/gnu/${pkgname}/rel${pkgver}/${pkgname}-${pkgver}.tar.xz{,.sig})
validpgpkeys=('44A088E295C3A722C450590EC9EF76DEB74EE762'
              '3EEE51D1355B8EC40D9F3122495143D05D0712D1') # Bruce Korb <bkorb@gnu.org>
sha512sums=('5f12c982dbe27873f5649a96049bf019ff183c90cc0c8a9196556b0ca02e72940cd422f6d6601f68cc7d8763b1124f2765c3b1a6335fc92ba07f84b03d2a53a1'
            'SKIP')

prepare() {
  cd $pkgname-$pkgver
  sed -i 's/ -Werror / /' configure
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check -j1
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  # Remove unrequired RPATH from binaries
  for i in ${pkgdir}/usr/bin/*; do
    if chrpath --list "$i"; then
      chrpath --delete "$i";
    fi
  done
}
